import re
from typing import Dict


class Hero(Dict):
    def __init__(self, info_str) -> None:
        self.info = info_str
        self["英雄名"] = self.__match(r"(?<=\|)英雄名=(.*?)(?=\n)")
        self["转职路线"] = []
        self["天赋名称"] = self.__match(r"(?<=\|)天赋名称=(.*?)(?=\n)")
        self["职业SP天赋名称"] = self.__match(r"(?<=\|)职业SP天赋名=(.*?)(?=\n)")
        self["觉醒技能"] = self.__match(r"(?<=\|)觉醒技能=(.*?)(?=\n)")

    def __match(self, format):
        value = re.search(format, self.info, re.MULTILINE)
        return value.group(1) if value else ""